#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 502;

int n;
LL edges[N][N];
int counts[N][N];
LL mindis[N];
pair<int,int> pairs[N];

struct Node{
    LL dis;
    int p;
    Node(){}
    Node(LL dis_,int p_):dis{dis_},p{p_}{}
    bool operator<(const Node& node)const{
        return dis>node.dis;
    }
};

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%lld",&edges[i][j]);
        }
    }
    memset(counts,0,sizeof(counts));
    for(int i=0;i<n;i++){
        memset(mindis,0x5f,sizeof(mindis));
        memset(pairs,0,sizeof(pairs));
        mindis[i] = 0;
        priority_queue<Node> que; 
        que.push(Node(0,i));
        while(!que.empty()){
            Node node = que.top();
            que.pop();
            int p = node.p;
            LL cdis = node.dis;
            if(cdis>mindis[p]) continue;
            for(int j=0;j<n;j++){
                if(j==p) continue;
                if(cdis+edges[j][p]<mindis[j]){
                    mindis[j] = cdis+edges[j][p];
                    counts[pairs[j].first][pairs[j].second]--;
                    counts[pairs[j].second][pairs[j].first]--;
                    pairs[j] = make_pair(j,p);
                    counts[j][p]++;
                    counts[p][j]++;
                    que.push(Node(mindis[j],j));
                }
                else if(cdis+edges[j][p]==mindis[j]){
                    counts[pairs[j].first][pairs[j].second]--;
                    counts[pairs[j].second][pairs[j].first]--;
                    pairs[j] = make_pair(0,0);
                }
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) printf("0");
            else if(counts[i][j]>0){
                printf("1");
            }
            else{
                printf("0");
            }
        }
        printf("\n");
    }
    return 0;
}